cd /d "%~dp0"
powershell -c "set-executionpolicy unrestricted"
for /f %%p in ('powershell .\getLocalResource.ps1 Ruby') do set RUBYPATH=%%p
for /f %%p in ('powershell .\getLocalResource.ps1 Git') do set GITPATH=%%p

7za x ruby-1.9.2-p180-i386-mingw32.7z -y -o"%RUBYPATH%"
7za x DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe -y -o"%RUBYPATH%\devkit"

md "%RUBYPATH%\home"

set PATH=%PATH%;%RUBYPATH%\ruby-1.9.2-p180-i386-mingw32\bin;%GITPATH%\bin

cd /d "%RUBYPATH%\devkit"
ruby dk.rb init
echo - %RUBYPATH%\ruby-1.9.2-p180-i386-mingw32 >> "%RUBYPATH%\devkit\config.yml"
ruby dk.rb install

call gem install specific_install --no-ri --no-rdoc
call gem specific_install -l http://github.com/eventmachine/eventmachine.git
call gem install bundler thin --no-ri --no-rdoc

echo y| cacls "%RUBYPATH%" /grant everyone:f /t

exit /b 0